<?php
	include "fonctions.php";
	session_start();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
	<head>
		<meta content="text/html;charset=UTF-8" http-equiv="Content-Type" />
		<link media="all" href="feuille.css" type="text/css" rel="stylesheet" />
		<script type="text/javascript" src = "JavaScript/newUser.js"></script>
		<?php
			if (isset($_POST['ident_ajout']))
			{
				if ($_POST['mdp_ajout'] == $_POST['Confirmmdp_ajout'])
				{
					db_connect();
					
					$mdp = $_POST['ident_ajout']."ov(k4G(y|ypSDWC".$_POST['mdp_ajout']."TO92|Q+5R5E9=8";
					$password = hash('sha256',$mdp);
					$pseudo = $_POST['ident_ajout'];
					$prenom = $_POST['prenom_ajout'];
					$nom = $_POST['nom_ajout'];
					$date_naissance = $_POST['naissance_ajout'];
					$sexe = $_POST['sexe_ajout'];
					
					$req = "INSERT INTO contributeurs VALUES ('$pseudo', '$password', '$prenom', '$nom', $date_naissance, $sexe, 'contributeur');";
					
					mysql_query($req) or die (mysql_error());
					
					$req = "INSERT INTO inscriptions VALUES ('$pseudo', 'Libre');";
					
					mysql_query($req) or die (mysql_error());
					
					$_SESSION['idUtil'] = $pseudo;
					$_SESSION['etatUser'] = "contributeur";
					
					echo '<meta http-equiv="Refresh" content="0;url=\'espace_adherents.php\'" />';
				}
			}
		?>
		<title>LMLP: Inscriptions</title>
	</head>
	
	<body>
		<?php en_tete(); ?>

		<div id="contenu">
			<?php menu_lateral_droit(); ?>
			
			<div id="texte">
				<?php
					vousetesici("Inscription");
				?>

				<h1 id = "titreAjout">S'inscrire</h1>
				<p class = "p_sous_h1">
					Pour vous inscrire, veuillez remplir le formulaire ci-dessous, tous les champs sont aubligatoires.
				</p>
				<form action="newUser.php" id = "form_ajout" name = "form_ajout" method="post">
					<fieldset>
						<legend>Identification</legend>
						
						<label for = "ident_ajout">Identifiant : </label>
						<input type = "text" id = "ident_ajout" name="ident_ajout" /><br/><br />

						<label for = "mdp_ajout">Mot de passe : </label>
						<input type = "password" id = "mdp_ajout" name="mdp_ajout" /><br/><br />

						<label for = "Confirmmdp_ajout">Confirmez le mot de passe : </label>
						<input type = "password" id = "Confirmmdp_ajout" name="Confirmmdp_ajout" /><br/><br />
					</fieldset>
					<fieldset>
						<legend>Informations</legend>
						
						<label for = "sexe_ajout">Sexe : </label>
						<select id = "sexe_ajout" name = "sexe_ajout">
							<option value = "0">F</option>
							<option value = "1">H</option>
						</select><br /><br />
						
						<label for = "nom_ajout">Nom : </label>
						<input type = "text" id = "nom_ajout" name = "nom_ajout" /><br /><br />
						
						<label for = "prenom_ajout">Prenom : </label>
						<input type = "text" id = "prenom_ajout" name = "prenom_ajout" /><br /><br />
						
						<label for = "naissance_ajout">Date de naissance (AAAA-MM-JJ) : </label>
						<input type = "text" id = "naissance_ajout" name = "naissance_ajout" /><br /><br />
					</fieldset>
					
					<input type="button" name="creerCompte" value="S'inscrire"/><br /><br /><br />
				</form>

<?php

echo "</div>";
echo "</div>";
pied_page();

?>